package com.ruoyi.socket.api;

import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.gams.domain.GamsAppVersion;
import com.ruoyi.gams.service.IGamsAppVersionService;
import com.ruoyi.gams.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "3.APP版本接口")
@RestController
@RequestMapping("/appversion-api")
public class AppVersionController
{
    @Autowired
    private IGamsAppVersionService appVersionService;

    @ApiOperation("3.1 最新版本")
    @ResponseBody
    @PostMapping("/lastversion")
    public Result<GamsAppVersion> lastversion(Integer appid)
    {
        log.info("appid = " + appid);
        GamsAppVersion firstByAppIdOrderByIdDesc = appVersionService.findFirstByAppIdOrderByIdDesc(appid);
        if (firstByAppIdOrderByIdDesc == null)
        {
            throw new GlobalException("APP ID 不正确");
        }
        return Result.success(firstByAppIdOrderByIdDesc);
    }

}
